<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.4/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-inline">

            <button type="button" class="layui-btn"><a href="product-management.html">返回上一页</a></button>
        </div>
        <table class="layui-hide" id="currentTableId1" lay-filter="currentTableFilter"></table>
    </div>
</div>


<script src="../lib/layui-v2.5.4/layui.js" charset="utf-8"></script>
<!--<script src="https://cdn.bootcss.com/axios/0.19.0/axios.min.js"></script-->
<script src="../js/product-manage.js" charset="utf-8"></script>

<script>

    // 获取上一个链接中的值
    function getUrlParam(yname) {
        var url = window.location.href;
        if (url != null && url.indexOf("?") !== -1) {
            var url_param = url.split("?")[1];
            var url_param_arr = url_param.split("&");
            for (var i = 0; i < url_param_arr.length; i++) {
                var tempParam = url_param_arr[i];
                var paramName = tempParam.split("=")[0];
                if (paramName === yname) {
                    return tempParam.split("=")[1]
                }
            }
        }
        return null;
    }

    layui.use(['form', 'table', 'layer'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer,
            table = layui.table;

        let pid=getUrlParam("pid");
        table.render({
            elem: '#currentTableId1',
            url: '/api/productyear/list/'+pid,
            cols: [[
                {field: 'yname', width: 580, title: '年份',  align: "center"},
                {field: 'yprice', width:580, title: '价格（元）', align: "center"},
            ]]
        });
    });


</script>

</body>
</html>